#define _CRT_SECURE_NO_WARNINGS 1
#include<vector>
#include<string>
#include<stack>
#include<map>
#include<functional>
using namespace std;
class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> st;
        map<string, function<int(int, int)>> opFuncMap =
        {
            {"+", [](int a,int b)->int {return a + b;}},
            {"-", [](int a,int b)->int {return a - b;}},
            {"*", [](int a,int b)->int {return a * b;}},
            {"/", [](int a,int b)->int {return a / b;}}
        };
        for (size_t i = 0; i < tokens.size(); i++)
        {
            if (opFuncMap.find(tokens[i]) != opFuncMap.end())
            {
                long long num2 = st.top();
                st.pop();
                long long num1 = st.top();
                st.pop();
                st.push(opFuncMap[tokens[i]](num1, num2));
            }
            else
            {
                st.push(stoi(tokens[i]));
            }
        }
        return st.top();
    }
};